﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySpaceID.SDK.OAuth.Common.Enums;
using System.IO;
using MySpaceID.SDK.Context;
using MySpaceID.SDK.Config;

namespace MySpaceID.SDK.Api
{
    public abstract class BaseApi
    {
        public SecurityContext Context { get; set; }
        
        public BaseApi(SecurityContext context)
        {
            this.Context = context;
        }

        protected bool ValidatePositiveId(int value, string key)
        {
            if (value < 1)
                throw new MySpaceException(string.Format("{0} must be greater than 0", key), 
                    MySpaceExceptionType.REQUEST_FAILED);
            return true;

        }

        protected bool ValidatePageParameters(int page, int pageSize)
        {
            if (page < 1)
                throw new MySpaceException("Page value must be greater than 0", MySpaceExceptionType.REQUEST_FAILED);
            if (pageSize < 1)
                throw new MySpaceException("PageSize value must be greater than 0", MySpaceExceptionType.REQUEST_FAILED);
            return true;

        }

    }
}
